package pl.kemot.model;

import java.util.ArrayList;
import java.util.List;

public class CustomerBO {

	public CustomerDTO saveOrUpdate(CustomerDTO customerDTO) {
		// symuluje zapis nowego klienta do BD
		if (customerDTO.getId() == null) {
			customerDTO.setId(10L);
		}
		return customerDTO;
	}

	public CustomerDTO getById(Long id) {
		// symuluje pobranie klienta z BD
		CustomerDTO customerDTO = prepare(1L);
		return customerDTO;
	}

	public List<CustomerDTO> getList() {
		List<CustomerDTO> list = new ArrayList<CustomerDTO>();
		list.add(prepare(1L));
		list.add(prepare(2L));
		list.add(prepare(3L));
		return list;
	}

	private CustomerDTO prepare(Long id) {
		CustomerDTO customerDTO = new CustomerDTO();
		customerDTO.setId(id);
		customerDTO.setFirstName("firstname" + id);
		customerDTO.setLastName("lastname" + id);
		customerDTO.setAge(10);
		return customerDTO;
	}
}
